package com.ssy.bus.controller;

import com.ssy.bus.pojo.Production;
import com.ssy.bus.service.IProductionService;
import com.ssy.bus.vo.ProductionVo;
import com.ssy.common.utils.PageResult;
import com.ssy.common.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;

/**
 * @author ssy
 */
@RestController
@RequestMapping("/production")
public class ProductionController {

    @Autowired
    private IProductionService productionService;

    /**
     * 分页查询
     *
     * @param productionVo
     * @return
     */
    @GetMapping("/loadAllProductionByPage")
    public PageResult loadAllProductionByPage(ProductionVo productionVo) {
        return this.productionService.loadAllProductionPage(productionVo);
    }

    /**
     * 添加生产厂家
     *
     * @param production
     * @return
     */
    @PostMapping("/addProduction")
    public Result addProduction(@RequestBody Production production) {
        production.setCreateTime(new Date());
        return this.productionService.insertProduction(production);
    }

    /**
     * 修改生产厂家
     *
     * @param production
     * @return
     */
    @PostMapping("/updateProduction")
    public Result updateProduction(@RequestBody Production production) {
        return this.productionService.updateProduction(production);
    }

    /**
     * 删除生产厂家
     *
     * @param id
     * @return
     */
    @DeleteMapping("/deleteProduction/{id}")
    public Result deleteProduction(@PathVariable Integer id) {
        return this.productionService.deleteProductionById(id);
    }

    /**
     * 批量删除生产厂家
     *
     * @param ids
     * @return
     */
    @DeleteMapping("/bathDeleteProduction/{ids}")
    public Result bathDeleteProduction(@PathVariable Integer[] ids) {
        return this.productionService.bathDeleteProduction(ids);
    }


}
